<template>
  <view>
    <view v-for="(item, index) in personList" :key="index" @click="onItemClick">
      {{ item }}
    </view>
    <button open-type="" hover-class="button-hover" @click="onLoginTap">
      登录
    </button>
    <view>用户个人信息:{{ userInfo }}</view>
  </view>
</template>

<script lang="ts">
import { useUserInfoStore } from "@/stores/user";
import { onLoad } from "@dcloudio/uni-app";
import { storeToRefs } from "pinia";
import { ref, defineComponent } from "vue";
import type { IHospitalItem } from "../index/types";

export default defineComponent({
  setup() {
    const personList = ref(["张三", "李四"]);
    const userStore = useUserInfoStore();
    const { userInfo } = storeToRefs(userStore);

    onLoad((option) => {
      const opt = option as IHospitalItem;
      console.log("hospital details onLoad: ", opt);
      console.log("opt.hospital_name: ", opt.hospital_name);
    });

    function onItemClick() {
      uni.navigateTo({
        url: "/pages/hospital-list/hospital-list",
      });
    }

    function onLoginTap() {
      uni.navigateTo({
        url: "/pages/login/login",
      });
    }

    return {
      personList,
      onItemClick,
      onLoginTap,
      userInfo,
    };
  },
});
</script>

<style lang="scss">
</style>
